import pygame

# 初始化Pygame
pygame.init()
size = width, height = 1000, 800
speed = [-2, 1]
bg = (255, 255, 255)
# 是否全屏
fyllcreen = False
# 创建指定大小的窗口 Surface
screen = pygame.display.set_mode(size)
# 设置窗口标题
pygame.display.set_caption("初次见面，请大家多多关照! ")
# 加在图片
turtle = pygame.image.load("游戏\\turtle.png")
# 获得图像的位置矩形
position = turtle.get_rect()

while True:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            exit(0)
        # 全屏（F11）
        if event.type == pygame.K_F11:
            print(5415)
            fyllcreen = not fyllcreen
            if fyllcreen == True:
                screen = pygame.display.setmode(pygame.display.list_modes()[0], FULLSCREEN | HWSURFACE)
            else:
                screen = pygame.display.set_mode(size)
    # 移动图像
    position = position.move(speed)

    if position.left < 0 or position.right > width:
        # 翻转图像.
        turtle = pygame.transform.flip(turtle, True, False)
        # 反方向移动
        speed[0] = -speed[0]
    if position.top < 0 or position.bottom > height:
        speed[1] = -speed[1]

    # 填充背景
    screen.fill(bg)
    # 更新图像
    pygame.display.flip()
    # 延迟10毫秒
    pygame.time.delay(10)
